package com.taobao.api.request;

import com.taobao.api.internal.util.RequestCheckUtils;
import java.util.Map;

import com.taobao.api.TaobaoRequest;
import com.taobao.api.internal.util.TaobaoHashMap;
import com.taobao.api.response.HanoiDataserviceReadResponse;
import com.taobao.api.ApiRuleException;
/**
 * TOP API: taobao.hanoi.dataservice.read request
 * 
 * @author auto create
 * @since 1.0, 2013-08-03 16:51:00
 */
public class HanoiDataserviceReadRequest implements TaobaoRequest<HanoiDataserviceReadResponse> {

	private Map<String, String> headerMap = new TaobaoHashMap();
	private TaobaoHashMap udfParams; // add user-defined text parameters
	private Long timestamp;

	/** 
	* 分配给调用方的名称信息，内部统计使用
	 */
	private String appName;

	/** 
	* 要查询的属性的id(Long型)。以json的数组的形式。所有属性的querykey必须相同，如有不同的需要分多次查询。属性的taobao.hanoi.ranges.get不为空时，值为key的拼接
	 */
	private String attrs;

	/** 
	* 查询的主键。如查询关系数据，主键是sellerId+buyerId，但sellerId是系统自动传过来的，所以只需要传"BUYERNICK"或"BUYERID"二选一。再例如查询类目数据，则需要传"CATEGORYID"。
	 */
	private String pk;

	public void setAppName(String appName) {
		this.appName = appName;
	}
	public String getAppName() {
		return this.appName;
	}

	public void setAttrs(String attrs) {
		this.attrs = attrs;
	}
	public String getAttrs() {
		return this.attrs;
	}

	public void setPk(String pk) {
		this.pk = pk;
	}
	public String getPk() {
		return this.pk;
	}

	public Long getTimestamp() {
		return this.timestamp;
	}

	public void setTimestamp(Long timestamp) {
		this.timestamp = timestamp;
	}

	public String getApiMethodName() {
		return "taobao.hanoi.dataservice.read";
	}

	public Map<String, String> getTextParams() {		
		TaobaoHashMap txtParams = new TaobaoHashMap();
		txtParams.put("app_name", this.appName);
		txtParams.put("attrs", this.attrs);
		txtParams.put("pk", this.pk);
		if(this.udfParams != null) {
			txtParams.putAll(this.udfParams);
		}
		return txtParams;
	}

	public void putOtherTextParam(String key, String value) {
		if(this.udfParams == null) {
			this.udfParams = new TaobaoHashMap();
		}
		this.udfParams.put(key, value);
	}

	public Class<HanoiDataserviceReadResponse> getResponseClass() {
		return HanoiDataserviceReadResponse.class;
	}

	public void check() throws ApiRuleException {
		RequestCheckUtils.checkNotEmpty(appName,"appName");
		RequestCheckUtils.checkNotEmpty(attrs,"attrs");
		RequestCheckUtils.checkNotEmpty(pk,"pk");
	}

	public Map<String, String> getHeaderMap() {
		return headerMap;
	}
}
